package com.deepclassifieds.daas.api.jdbc.name;

import java.io.Serializable;

import com.deepclassifieds.daas.common.Name;
import com.deepclassifieds.daas.common.Reject;

public final class ColumnName implements Serializable, Comparable<ColumnName> {

	private static final long serialVersionUID = 20110222003718L;

	private final Name columnName;
	
	public ColumnName(Name columnName) {
		Reject.ifNull(columnName);
		this.columnName = columnName;
	}

	@Override
	public int hashCode() {
		return columnName.toString().hashCode();
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj) return true;
		if (obj == null) return false;
		if (getClass() != obj.getClass()) return false;
		ColumnName other = (ColumnName) obj;
		return columnName.toString().equals(other.columnName.toString());
	}

	@Override
	public String toString() {
		return columnName.toString();
	}

	@Override
	public int compareTo(ColumnName value) {
		return columnName.toString().compareTo(value.columnName.toString());
	}
	
}
